﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microhard.Core.DBUtility;
using Micrhard.FMCG.Server.Validator;
using Microhard.Notifications.Attrs;
using Micrhard.FMCG.Server.Notification;
using Microhard.Notifications.Enum;

namespace Micrhard.FMCG.Server.Models
{
    [AttrOfNotiMsgTemplate(Template = typeof(ApproveCommentTemplate), MsgType = MsgType.Mail, GetSpecificUserClass = typeof(DailyApproveNotifi))]
    [FluentValidation.Attributes.Validator(typeof(DailyModelValidator))]
    public class DailyModel : BasePermissionModel
    {
        [ModelPKID]
        public Guid DailyID { set; get; }
        public Guid EmployeeID { set; get; }
        public string EmployeeName { set; get; }
        public string UserName { set; get; }
        public string TodayPlan { set; get; }
        public string TodayFinished { set; get; }
        public string Question { set; get; }
        public string Help { set; get; }
        public DateTime CreateTime { set; get; }
        public string Comment { set; get; }
        public string TommrowPlan { set; get; }
        public List<ProtalSubKAPlanModel> TommrowPlanProtalSubKA { set; get; }
        public string TommrowPlanProtalSubKANames
        {
            get
            {
                StringBuilder sb = new StringBuilder();
                if (TommrowPlanProtalSubKA != null)
                {
                    TommrowPlanProtalSubKA.ForEach(i =>
                    {
                        sb.Append(i.Name);
                        sb.Append(",");
                    });
                }
                return sb.ToString();
            }
        }

        public List<DailyCommentModel> ApproveComment { set; get; }
        public string ApproveCommentDisplay
        {
            get
            {
                if (this.ApproveComment != null)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (var a in ApproveComment)
                    {
                        sb.AppendLine(a.OperatorName + ":" + a.Content);
                    }
                    return sb.ToString();
                }
                return string.Empty;
            }
        }
    }
}
